<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "edu_question".
 *
 * @property int $id
 * @property int $user_id 提问者用户id
 * @property string $context 提问的问题
 * @property string $images 图片集合
 * @property int $answer_count 回复或者评论的数量
 * @property int $status 0禁用 1启用 1默认
 * @property int $create_time 创建时间
 * @property int $collect_count 收藏数
 * @property int $collect_base 收藏基数
 */
class EduQuestion extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'edu_question';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['user_id', 'create_time'], 'required'],
            [['user_id', 'answer_count', 'status', 'create_time', 'collect_count', 'collect_base'], 'integer'],
            [['images'], 'string'],
            [['context'], 'string', 'max' => 1000],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'user_id' => '用户 ID',
            'context' => '内容',
            'images' => '图片',
            'answer_count' => '回答数',
            'status' => '状态',
            'create_time' => '时间',
            'collect_count' => '收藏数',
            'collect_base' => '收藏基数',
        ];
    }

    /**
     * 关联用户表
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(EduUser::class, ['id' => 'user_id']);
    }
}
